package demo01;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;

public class Homework8 {
	public static void main(String[] args) {
		//准备牌
				ArrayList<String> poker=new ArrayList<String>();
				ArrayList<Integer> pokercode=new ArrayList<Integer>();
				ArrayList<Integer> play1code=new ArrayList<Integer>();
				ArrayList<Integer> play2code=new ArrayList<Integer>();
				ArrayList<Integer> play3code=new ArrayList<Integer>();
				ArrayList<Integer> dipai=new ArrayList<Integer>();
				HashMap<Integer,String> map=new HashMap();
				int value=0;
				//定义两个数组
				String[] colors={"♠","♣","♥","♦"}; 
				String[] numbers={"2","A","K","Q","J","10","9","8","7","6","5","4","3"};
				poker.add("大王");poker.add("小王");
				//组装52张牌
				for(String number:numbers){
					for(String color:colors){
						poker.add(color+number);
					}
				}
				for(String pokers:poker){
					map.put(value,pokers);
					value++;
				}
				for (int code : map.keySet()) {			
						pokercode.add(code);
					 }
				//洗牌
				Collections.shuffle(pokercode);	
				//摸牌
				for(int i=0;i<pokercode.size();i++){
					//每一张牌
					if(i<=50){
						if(i%3==0){
							play1code.add(pokercode.get(i));
						}else if(i%3==1){
							play2code.add(pokercode.get(i));
						}else{
							play3code.add(pokercode.get(i));
						}
					}else{
						dipai.add(pokercode.get(i));
					}
				}
				//排序
				Collections.sort(play1code);
				Collections.sort(play2code);
				Collections.sort(play3code);
				System.out.print("底牌：");//看牌
				for(Integer p:dipai){
					if(map.containsKey(p)){
						System.out.print(map.get(p));
					}
				}System.out.println("");System.out.print("老王：");
				for(Integer p:play1code){
					if(map.containsKey(p)){
						System.out.print(map.get(p));
					}
				}
				System.out.println("");
				System.out.print("老李：");
				for(Integer p:play2code){
					if(map.containsKey(p)){
						System.out.print(map.get(p));
					}
				}
				System.out.println("");
				System.out.print("老刘：");
				for(Integer p:play3code){
					if(map.containsKey(p)){
						System.out.print(map.get(p));
					}
				}
			
	}
}
